/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import pojo.KhuVucPoJo;
import util.DataProvider;

/**
 *
 * @author Kanet
 */
public class KhuVucDao {
            public static ArrayList<KhuVucPoJo> laydanhsachKhuVuc()
    {
        ArrayList<KhuVucPoJo> arr = new ArrayList<KhuVucPoJo>();
        String sql = "SELECT * FROM khuvuc";
        DataProvider dp = new DataProvider();
        dp.open();
        
        try{
            ResultSet rs = dp.executeQuery(sql);
            while (rs.next()){
               KhuVucPoJo kv = new KhuVucPoJo();
               kv.setIdKhuVuc(rs.getInt("idKhuVuc"));
                kv.setTenKhuVuc(rs.getString("tenKhuVuc"));
                arr.add(kv);
            }            
        }
        catch(SQLException ex){
            System.out.println(ex.getMessage());                        
        }
        dp.close();
        return arr;
    }
}
